Child-bands

Let us examine the case when one of the lines in a report of "label" type, may have a variable size. To simulate the situation using our our example, let us reduce the "Bio."Common Name"" object width to 2.5 cm, and enable the "Stretch" option for it. Let us also enable stretching in the "First level data" band. Enable all the frame lines in all objects so that the principle of the stretching function would become clear. We will receive a report of the following kind:

You see, that in the first case the first object contains a longer text, and that is why it was stretched in two lines. Thus, the object (located underneath it and linked to the Bio."Length (sm)" field) was shifted down. That happens because all the objects have the "Shift" property enabled by default (or ShiftMode = smAlways in the object inspector). Such objects shift downwards if there is a stretchable object above them (the "Text" object with the "Stretch" property enabled). The height value, by which the object shifts, depends on how the object from above is stretched.

However, it is unacceptable in our case, since we need the object with the "Length, cm." text to be shifted as well. To perform this, there is a special band type in FastReport, "Child-band." It is linked to (and is displayed after) the basic band. Let us update our report:

To link the basic component to the child one, let us set the "Child = Child1" property in the object inspector. Now, each time you print the basic band, the child one would be displayed as well:

As you can see, now the title is typed exactly where it is supposed to be. In order to avoid child-band’s transfering to the next page (which basically means, it will be separated from the basic band), enable the "Keepchild" property for the basic band ("KeepChild" in the object inspector).